* sysdep.c (closedir): Don't free directory buffer if it looks
authorJim Blandy <jimb@redhat.com>
Wed, 16 Jun 1993 20:31:01 +0000 (20:31 +0000)
committerJim Blandy <jimb@redhat.com>
Wed, 16 Jun 1993 20:31:01 +0000 (20:31 +0000)
like it and the DIR were malloced together.

src/sysdep.c

index e696cb3d352588bb543447b6e5a9dfb298cbf41f..2bbdf2640f2ba145e055de7b09aeff37ef96f16d 100644 (file)
@@ -2927,7 +2927,11 @@ closedir (dirp)
      register DIR *dirp;              /* stream from opendir */
 {
   sys_close (dirp->dd_fd);
-  xfree ((char *) dirp->dd_buf);       /* directory block defined in <dirent.h> */
+
+  /* Some systems allocate the buffer and the DIR all in one block.
+     Why in the world are we freeing this ourselves anyway?  */
+  if (dirp->dd_buf != (char *)(dirp + 1))
+    xfree ((char *) dirp->dd_buf); /* directory block defined in <dirent.h> */
   xfree ((char *) dirp);
 }
 #endif /* not AIX */